package com.hjxr.quota.sdoc.service.impl;

import com.hjxr.quota.sdoc.domain.TFileInfo;
import com.hjxr.quota.sdoc.mapper.TFileInfoMapper;
import com.hjxr.quota.sdoc.service.FileInfoService;
import com.hjxr.quota.sdoc.util.SnowflakeIdWorker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 文件处理类
 *
 * @author JaredJia
 */
@Service
public class FileInfoServiceImpl implements FileInfoService {

    @Autowired
    TFileInfoMapper tFileInfoMapper;

    @Override
    public int addFileInfo(TFileInfo fileInfo) {
        fileInfo.setId(SnowflakeIdWorker.getUUID() + SnowflakeIdWorker.getUUID());
        return tFileInfoMapper.insertSelective(fileInfo);
    }

    @Override
    public List<TFileInfo> selectFileByParams(TFileInfo fileInfo) {
        return tFileInfoMapper.selectFileByParams(fileInfo);
    }

    @Override
    public List<TFileInfo> selectFileList(TFileInfo file) {
        return tFileInfoMapper.selectFileList(file);
    }

    @Override
    public int deleteFile(TFileInfo tFileInfo) {
        TFileInfo t = new TFileInfo();
        t.setId(tFileInfo.getId());
        t.setDelFlag("1");
        return tFileInfoMapper.updateByPrimaryKeySelective(t);
    }
}
